Skip to content

Conversation

@ThrawnCA
Copy link
Contributor

I have added unit tests showing incorrect behaviour of StringUtils.abbreviate on short strings (between abbrevMarker.length + 1 and abbrevMarker.length * 2).

The documentation states that the offset character will always appear somewhere in the result, but when an offset is applied to a short string, it may not be.

@ThrawnCA
Copy link
Contributor Author

I'm unsure what's the best approach to fixing this. Should the documentation be updated to reflect the fact that for short strings, the offset marker might not be present in the result? Should the logic be changed so that the offset marker is present, and if so, what is the most efficient way?

@garydgregory
Copy link
Member

The failing test:

        // abbreviating a shorter string allows maxWidth < 7
        assertEquals("...efg", StringUtils.abbreviate("abcdefg", 5, 6));

looks like a bug indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants